package com.szml.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.szml.entity.OperationRecord;
import com.szml.result.R;
import com.szml.result.Result;
import com.szml.service.OperationRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Slf4j
@RestController
@RequestMapping("/record")
public class OperationRecordController {

    @Autowired
    private OperationRecordService operationRecordService;

    @GetMapping("/page")
    public Result<Page> pagelist(@RequestParam(required = false) Integer page,
                            @RequestParam(required = false) Integer pageSize) {
        log.info("page = {}, pageSize = {}", page, pageSize);
        // 设置默认值
        if (page == null) {
            page = 1;
        }
        if (pageSize == null) {
            pageSize = 10;
        }
        // 构造分页构造器
        // 调用Service层方法进行查询
        Page<OperationRecord> resultPage = operationRecordService.page(new Page<>(page,pageSize));
        // 返回结果
        return Result.success(resultPage);
        }

}